package com.example.foobar.dao.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.foobar.dao.service.DaDataAnalysisDaoService;
import com.example.foobar.dto.DABaseDTO;
import com.example.foobar.entity.DaDataAnalysis;
import com.example.foobar.mapper.DaDataAnalysisMapper;
import com.example.foobar.param.DaDataAnalysisPageParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

/**
 * 新增用户数记录 服务实现类
 *
 * @author 郑英奔
 * @since 2021-05-31
 */
@Slf4j
@Service
public class DaDataAnalysisDaoServiceImpl extends BaseServiceImpl<DaDataAnalysisMapper, DaDataAnalysis> implements DaDataAnalysisDaoService {

    @Autowired
    private DaDataAnalysisMapper daDataAnalysisMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveDaDataAnalysis(DaDataAnalysis daDataAnalysis) throws Exception {
        return super.save(daDataAnalysis);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateDaDataAnalysis(DaDataAnalysis daDataAnalysis) throws Exception {
        return super.updateById(daDataAnalysis);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteDaDataAnalysis(Long id) throws Exception {
        return super.removeById(id);
    }

    @Override
    public Paging<DaDataAnalysis> getDaDataAnalysisPageList(DaDataAnalysisPageParam daDataAnalysisPageParam) throws Exception {
        Page<DaDataAnalysis> page = new PageInfo<>(daDataAnalysisPageParam, OrderItem.desc(getLambdaColumn(DaDataAnalysis::getCreateTime)));
        LambdaQueryWrapper<DaDataAnalysis> wrapper = new LambdaQueryWrapper<>();
        IPage<DaDataAnalysis> iPage = daDataAnalysisMapper.selectPage(page, wrapper);
        return new Paging<DaDataAnalysis>(iPage);
    }


}
